And this video we're creating another variant of the S&P 500 return triangle and I call this the return
radar because it pretty much looks like a weather radar.
The only difference to the return triangles that the return rate US based on weekly returns instead
of annual returns.
And that means that we have a higher resolution a definition here and that might give us some more insight
and the code to pretty much looks the same.
So I will only highlight the differences and first of all we import the necessary libraries here and
we also import our data
so here we are for the S&P 500 price data.
And now comes the very first difference.
So we read sample the S&P 500 price data.
And before we read sample to emulate frequency and here we read sample to weekly frequency and we take
the very last trading price of each week so that's the weekly data frame and then in the next step we
calculate weekly or lock return.
So that's what we are doing here.
And we actually annualize the weekly returns by multiplying with fifty two.
And by doing so we're creating a new column return.
And we also drop the very first row.
So let's have a look.
So here we have the weekly closing prices and the weekly returns the annualized
and in total our period includes one thousand five hundred sixty five weeks.
And uh that means uh that in our next step we are creating one thousand five hundred sixty five new
columns and actually each column stands for a rolling statistic.
So we have for the rolling mean return for a period of one week two weeks three weeks until one thousand
five hundred sixty five weeks.
And therefore we created our list.
Windows so here we have a list with integers from 1565 till 1 and then finally we creating 1565 new
columns with the for loop here and the column labels should be 1 week to week and so on and again here
we calculate the rolling mean return.
Let's have a look here.
So this might take a while.
So here we have our weekly data frame with um here on the right hand side the column 1 week and on the
left hand side of the column one thousand five hundred sixty five weeks and still we have for the columns
close and return our data frame and we can simply drop them and we save the resulting data frame and
the variable triangular
and finally we can create our plot slow here our seaborne heat map and let's have a look here
so that's our return triangle with a high resolution or high definition and that pretty much looks like
a weather radar.
So here we can see the huge Harry Kane in the year 2000 and 2001 and also the huge Harry Kane in 2 8
2 9 and the financial crisis and yes actually the combination of both hurricanes.
So if your investment experienced both hurricanes then still you are in the negative numbers here and
depending on the investment period.
So we can see here with the short periods there are many isolated thunderstorms.
So this is a pretty random year if your investment period is uh let's say one year or one and a half
years then that's pretty much gambling if you end up with a gain or loss and by increasing the investment
period the returns are getting a less volatile and better predictable actually.
So for example here you are pretty much in the double digit area and here you are still influenced by
the hurricanes of the year 2000 and 2008 2009.
So that's a pretty informative year and with this we are finished with the return triangles and radars
and I hope to see you also in the next video by.